<?php

/**
 * Cliente form base class.
 *
 * @method Cliente getObject() Returns the current form's model object
 *
 * @package    zing
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseClienteForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'           => new sfWidgetFormInputHidden(),
      'razonSocial'  => new sfWidgetFormInputText(),
      'cuitCuil'     => new sfWidgetFormInputText(),
      'tipoIva'      => new sfWidgetFormChoice(array('choices' => array('Inscripto' => 'Inscripto', 'No Inscripto' => 'No Inscripto', 'Monotributista' => 'Monotributista', 'Responsable Inscripto' => 'Responsable Inscripto', 'Consumidor Final' => 'Consumidor Final'))),
      'direccion'    => new sfWidgetFormInputText(),
      'ciudad'       => new sfWidgetFormInputText(),
      'codigoPostal' => new sfWidgetFormInputText(),
      'pais'         => new sfWidgetFormInputText(),
      'telefono'     => new sfWidgetFormInputText(),
      'celular'      => new sfWidgetFormInputText(),
      'email'        => new sfWidgetFormInputText(),
      'created_at'   => new sfWidgetFormDateTime(),
      'updated_at'   => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'           => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'razonSocial'  => new sfValidatorString(array('max_length' => 30)),
      'cuitCuil'     => new sfValidatorString(array('max_length' => 14)),
      'tipoIva'      => new sfValidatorChoice(array('choices' => array(0 => 'Inscripto', 1 => 'No Inscripto', 2 => 'Monotributista', 3 => 'Responsable Inscripto', 4 => 'Consumidor Final'))),
      'direccion'    => new sfValidatorString(array('max_length' => 30, 'required' => false)),
      'ciudad'       => new sfValidatorString(array('max_length' => 30, 'required' => false)),
      'codigoPostal' => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'pais'         => new sfValidatorString(array('max_length' => 30, 'required' => false)),
      'telefono'     => new sfValidatorString(array('max_length' => 30, 'required' => false)),
      'celular'      => new sfValidatorString(array('max_length' => 30, 'required' => false)),
      'email'        => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'created_at'   => new sfValidatorDateTime(),
      'updated_at'   => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Cliente', 'column' => array('razonSocial'))),
        new sfValidatorDoctrineUnique(array('model' => 'Cliente', 'column' => array('cuitCuil'))),
      ))
    );

    $this->widgetSchema->setNameFormat('cliente[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Cliente';
  }

}
